﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.CommandBars;

namespace VSAddInFramework
{
    // Provide functions to add command to appropriate toolbars, context menus.
    public static class VSCommandUIMgr
    {
        public static bool CreateToolBar(string toolbarName) { return true; }
        public static CommandBarButton AddCommandToToolbar(VSCommand cmd, string toolbarName)
        {
            // Add this menu in the Context Menu
            CommandBars commandBars = VSAddInMgr.Instance.Application.CommandBars as CommandBars;
            CommandBar commandBar = commandBars[toolbarName] as CommandBar;
            Debug.Assert(commandBar != null);

            // Need to avoid insert it muliple times
            CommandBarButton cmdBtn = null;
            if(commandBar != null)
            {
                cmdBtn = cmd.InternalCommand.AddControl(commandBar, 1) as CommandBarButton;
            }

            return cmdBtn;
        }
    }
}
